#include "mlTriangle.h"
#include <math.h>
#include <stdio.h>
#include <string.h>

void
mlTrianglePrint(const float *a)
{
	printf("[(%f, %f, %f), (%f, %f, %f), (%f, %f, %f)]", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
}

void
mlTriangleCopy(const float *a, float *result)
{
	memcpy(result, a, 3 * 3 * sizeof(float));
}

void
mlTriangleBoundSphere(const float *a, float *result)
{
	result[0] = (a[0 * 3 + 0] + a[1 * 3 + 0] + a[2 * 3 + 0]) / 3.0f;
	result[1] = (a[0 * 3 + 1] + a[1 * 3 + 1] + a[2 * 3 + 1]) / 3.0f;
	result[2] = (a[0 * 3 + 2] + a[1 * 3 + 2] + a[2 * 3 + 2]) / 3.0f;
	result[3] = sqrtf(powf(result[0] - a[0 * 3 + 0], 2) + powf(result[1] - a[0 * 3 + 1], 2) + powf(result[2] - a[0 * 3 + 2], 2));
}
